package com.douyang.controller;

import cn.dev33.satoken.annotation.SaCheckRole;
import com.douyang.base.model.PageResult;
import com.douyang.base.model.Result;
import com.douyang.dto.CreateLiveDTO;
import com.douyang.dto.LiveListDTO;
import com.douyang.pojo.Live;
import com.douyang.service.LiveService;
import com.douyang.vo.GetChannelKeyVO;
import com.douyang.vo.LiveListVO;
import com.douyang.vo.LiveVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author xiaoma
 * @since 2025-03-07
 */
@RestController
@RequestMapping("/video/live")

public class LiveController {

    @Autowired
    private LiveService liveService;

    @GetMapping("/getLive")
    @SaCheckRole("presenter")
    public Result<LiveVO> getLive(){
        return liveService.getLive();
    }

    @PostMapping("/createLive")
    @SaCheckRole("presenter")
    public Result<String> createLive(@RequestBody CreateLiveDTO createLiveDTO){
        return Result.success(liveService.createLive(createLiveDTO));

    }

    @GetMapping("/getAppName")
    @SaCheckRole("presenter")
    public Result<String> getAppName(){
        return Result.success(liveService.getAppName());
    }

    @DeleteMapping("/stopLive")
    @SaCheckRole("presenter")
    public Result<String> stopLive(){
        liveService.stopLive();
        return Result.success("ok");
    }

    @PostMapping("/getLiveList")
    public Result<PageResult<LiveListVO>> getLiveList(@RequestBody LiveListDTO liveListDTO){
        return Result.success(liveService.getLiveList(liveListDTO));
    }

    @GetMapping("/getLiveByPresenterId")
    public Result<LiveVO> getLiveById(Long presenterId){
        return Result.success(liveService.getLiveById(presenterId));
    }
}
